<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.anhry.app.safety.util.Util"%>
<%@ include file="/WEB-INF/pages/share/taglib.jsp"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>用户列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="<%=basePath+Util.SKIN%>/css/right.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="<%=basePath%>/js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>/js/dbdialog/lhgdialog.min.js<%=Util.LHGDIALOG%>"></script>
	<script src="<%=basePath%>/js/checkbox1.js" type="text/javascript"></script>
	<script type="text/javascript" src="<%=path%>/js/selected.js"></script>
	<script type="text/javascript" src="<%=basePath %>/js/util.js"></script>
	<script type="text/javascript">
		function resetPwd(uid){
			var urls="<%=basePath%>/admin/sys_resetPwd.action?objId="+uid;
			$.get(urls,function(data){
				if(data=="0"){
					msgDialog("重置密码失败！", "fail.png");
				}else if(data=="1"){
					msgDialog("重置密码成功！", "succ.png");
				}
			});
			return;
		}
		function userClock(uid,clock){
			var urls="<%=basePath%>/admin/sys_userClock.action?objId="+uid+"&clock="+clock;
			$.get(urls,function(data){
				if(data=="0"){
					msgDialog("操作失败！","fail.png");
				}else if(data=="1"){
					document.userForm.submit();
				}
			});
			return;
		}
		$(function(){
			initSelArray('cUnit:1','cDept:1');
			var cGrade = '${cGrade}';
			var cUnit = '${cUnit}';
			var cDept = '${cDept}';
			if(null!=cGrade && cGrade!=""){
				changeGrade(cGrade);
			}
	   		if(cUnit!=null && cUnit!=""){
	   			changeUnit(cUnit);
	   			selected('cUnit',cUnit);	//加载选中部门
	   		}
	   		if(cDept!=null && cDept!=""){
	   			selected('cDept',cDept);	//加载选中单位
	   		}
		});
		function changeGrade(rid){
	   		var urls='<%=basePath%>/admin/sys_loadDept.action?gradeId='+rid
	   		buildSelect(rid, 'cUnit',urls,'1');
	   	}
	   	function changeUnit(uid){
	   		var rid=document.getElementById("cGrade").value;
	   		var urls="<%=basePath%>/admin/sys_loadDept.action?unitId="+uid+"&gradeId="+rid;
	   		buildSelect(uid, 'cDept',urls,'1');
	   	}
	   	function opdlg(uid){
		   	$.dialog({id:'userInfo',title:'用户信息查看',width:540,height:300,max: false,min: false,content: 'url:<%=path%>/admin/sys_userShow.action?objId='+uid+'',
			   	cancelVal: '关闭',
			   	cancel: true /*为true等价于function(){}*/
			});
		}
	</script>
  </head>
  
  <body>
	<div  class="body-box">
		<div class="map">
			<div class="map_con">
				您当前的位置：系统管理 &gt; 用户管理
			</div>
		</div>
		<div id="container">
			<fieldset class="serarch_set">
				<legend>
			  		<div class="search">查询条件</div>
			  	</legend>
			  	<form action="<%=basePath%>/admin/sys_userList.action?search=1" method="post" name="userForm">
			   		<label>用户单位：</label> 
			   			<s:select list="gradeList" name="cGrade" listKey="id" listValue="gradeName" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;" id="cGrade" onchange="changeGrade(this.value);"></s:select>
			   			<s:select list="#{}" name="cUnit" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="cUnit" onchange="changeUnit(this.value);"></s:select>
			   			<s:select list="#{}" name="cDept" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;" id="cDept"></s:select>
			   			<br/>
			   		<label>用户角色：</label> 
			   			<s:select list="roleList" name="cRole" listKey="id" listValue="roleName" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;"></s:select> 
			   			用户职务：<s:select list="zwList" name="cZw" listKey="id" listValue="name" headerKey="" headerValue="请选择" theme="simple" cssStyle="width:155px;margin-left:5px;"></s:select>
			   			<br/>
			   		<label>名称：</label><input type="text" name="keyWord" value="${keyWord }" size="50%"><input type="submit" value="搜索" class="link_input" name="btnsx">
			   		<input type="hidden" name="num" value="${page.num }">
			   		<input type="hidden" name="size" value="${page.size }">
			  	</form>
			</fieldset>
		  	<table border="0" cellpadding="0" cellspacing="0" class="mytable">
		   		<thead>
			    	<tr class="fixedHeaderTr">
			     		<th width="5%">选择</th>
			     		<th width="5%">序号</th>
			     		<th width="10%">用户名称</th>
			     		<th width="10%">真实姓名</th>
			     		<th width="10%">用户级别</th>
			     		<th width="10%">用户角色</th>
			     		<th width="20%">所属部门</th>
			     		<th width="10%">职务</th>
			     		<th width="5%">状态</th>
			     		<th width="15%">操作</th>
			    	</tr>
		   		</thead>
			   	<tbody>
			   		<s:if test="%{userList.size>0}">
			   			<s:iterator value="userList" id="obj" status="x">
				   			<tr>
					     		<td align="center"><input type="checkbox" name="objId" value="${obj.id }"/></td>
					     		<td align="center">${x.index+1+(page.num-1)*page.size}</td>
					     		<td align="center"><a href="javascript:opdlg('${obj.id }');">${obj.userName }</a></td>
					     		<td align="center">${obj.userRealName }</td>
					     		<td align="center">${obj.gradeName }</td>
					     		<td align="center">${obj.roleName }</td>
					     		<td align="left">${obj.unitName }<s:if test="%{#obj.deptName!=null}">—${obj.deptName }</s:if></td>
					     		<td align="center">
					     			<s:if test="%{#obj.userZw==1}">局长</s:if>
					     			<s:if test="%{#obj.userZw==2}">副局长</s:if>
					     			<s:if test="%{#obj.userZw==3}">处长</s:if>
					     			<s:if test="%{#obj.userZw==4}">副处长</s:if>
					     			<s:if test="%{#obj.userZw==5}">科长</s:if>
					     			<s:if test="%{#obj.userZw==6}">副科长</s:if>
					     			<s:if test="%{#obj.userZw==7}">主任</s:if>
					     			<s:if test="%{#obj.userZw==8}">副主任</s:if>
					     			<s:if test="%{#obj.userZw==9}">科员</s:if>
					     			<s:if test="%{#obj.userZw==10}">股长</s:if>
					     			<s:if test="%{#obj.userZw==11}">副股长</s:if>
					     			<s:if test="%{#obj.userZw==12}">股员</s:if>
					     		</td>
					     		<td align="center">${obj.isLock==0?'正常':'<font color="red">锁定</font>' }</td>
					     		<td align="center">
						     		<sp:permission module="user" permissionType="${UPDATE}">
						     			<a href="javascript:resetPwd('${obj.id}');">重置密码</a>
						     			<a href="<%=basePath %>/admin/sys_userUpdate.action?objId=${obj.id }&keyWord=${keyTemp}&cGrade=${cGrade }&cUnit=${cUnit }&cDept=${cDept }&cRole=${cRole }&cZw=${cZw }&num=${page.num }&size=${page.size }">修改</a>
						     		</sp:permission>
						     		<sp:permission module="user" permissionType="${DELETE}">
						     			<a href="javascript:void(0)" onclick="javascript:return confirmDg('您确定要删除此用户吗？','<%=basePath %>/admin/sys_userDele.action?objId=${obj.id }&keyWord=${keyTemp}&cGrade=${cGrade }&cUnit=${cUnit }&cDept=${cDept }&cRole=${cRole }&cZw=${cZw }&num=${page.num }&size=${page.size }' )">删除</a>
						     			<s:if test="%{#obj.isLock==0}"><a href="javascript:userClock('${obj.id}','1');">锁定</a></s:if>
						     			<s:else><a href="javascript:userClock('${obj.id}','0');">解锁</a></s:else>
						     		</sp:permission>
					     		</td>
					    	</tr>
			   			</s:iterator>
			    	</s:if>
			    	<s:else>
				    	<tr>
				     		<td align="center" colspan="11">暂无数据</td>
				    	</tr>
			    	</s:else>
			   	</tbody>
		  	</table>
		  	<div class="btn_page">
		  		<sp:permission module="user" permissionType="${CREATE}"><input type="button" class="link_input" value="添加用户" onclick="window.location.href='<%=basePath %>/admin/sys_userAdd.action'"/></sp:permission>
		  		<sp:permission module="user" permissionType="${DELETE}">
			  		<input type="button" name="button5" value=" 全 选 " onclick="selectAll('objId');" class="link_input">
					<input type="button" name="button4" value=" 反 选 " onclick="selectReverse('objId');" class="link_input">
					<input type="button" name="button3" value=" 清 空 " onclick="clearAll('objId');" class="link_input">
					<input type="button" name="button2" value=" 删 除 " onclick="dAll('objId','<%=basePath%>/admin/sys_userDele.action?objId=${obj.id }&keyWord=${keyTemp}&cGrade=${cGrade }&cUnit=${cUnit }&cDept=${cDept }&cRole=${cRole }&cZw=${cZw }&num=${page.num }&size=${page.size }&objId=',1);" class="link_input">
		  		</sp:permission>
		  	</div>
		  	<div class="page">
				<jsp:include flush="true" page="../share/fenye.jsp">
				    <jsp:param name="url4page" value="/admin/sys_userList.action?keyWord=${keyTemp}&cGrade=${cGrade }&cUnit=${cUnit }&cDept=${cDept }&cRole=${cRole }&cZw=${cZw }" />
			    </jsp:include>	    	
		    </div>
	 	</div>
	</div>
  </body>
  <s:if test="%{tip!=null}">
    	<script>
    		msgDialog('${tip}', 'succ.png');
    	</script>
    </s:if>
</html>
